﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace AirLinq.Providers.Sql {
	public class SqlSelect : SqlNode {
		private readonly SqlQueryExpressionBase _queryExpression;
		private readonly ReadOnlyCollection<SqlExpression> _orderBy;
		public SqlSelect(SqlQueryExpressionBase queryExpression, ReadOnlyCollection<SqlExpression> orderBy) {
			if (queryExpression == null) {
				throw new ArgumentNullException("queryExpression");
			}
			_queryExpression = queryExpression;
			_orderBy = orderBy;
		}
		public SqlQueryExpressionBase QueryExpression {
			get {
				return _queryExpression;
			}
		}
		public ReadOnlyCollection<SqlExpression> OrderBy {
			get {
				if (_orderBy != null && _orderBy.Count > 0) {
					return _orderBy;
				}
				return null;
			}
		}
		public override SqlNodeType NodeType {
			get {
				return SqlNodeType.Select;
			}
		}
	}
}
